<template>
  <div class="info" @click="openDetail()">
    <div class="title">{{ info.title }}</div>
    <div class="img">
      <img :src="info.image" class="bg" v-if="info.image" />
      <div class="video-btn" v-if="info.mp4_url" @click.stop="openVideo(info.mp4_url)"></div>
    </div>
    <div class="desc">{{ info.contents_html }}</div>
    <div class="con">
      <div class="btn">查看详情 <span class="icon3"></span></div>
      <div class="time">{{ info.add_time }}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    info: Object
  },
  methods: {
    openDetail() {
      this.$router.goto({
        path: '/articleDetail',
        query: {
          id: this.info.article_id
        }
      })
    },
    openVideo(url) {
      this.eventBus.$emit('openVideo', { title: '', url: url })
    }
  }
}
</script>

<style lang="less" scoped>
.info {
  width: 390px;
  height: 550px;
  overflow: hidden;
  padding: 40px 28px 0 28px;
  cursor: pointer;
  background: #ffffff;
  border-radius: 7px 7px 7px 7px;
  transition: all 0.2s;
  &:hover {
    background: #b8af9d;
    .title {
      color: #fff;
    }
    .desc {
      color: #fff;
    }
    .con {
      .btn {
        border-color: #fff;
        color: #fff;
        .icon3 {
          background: url(../assets/icon3-active.png) center center no-repeat;
          background-size: 100% 100%;
        }
      }
      .time {
        color: #fff;
      }
    }
  }
  .title {
    font-size: 20px;
    height: 58px;
    line-height: 29px;
    .ellipsis-n(2);
    font-weight: 700;
    margin-bottom: 21px;
    transition: all 0.2s;
  }
  .img {
    width: 334px;
    height: 210px;
    position: relative;
    margin-bottom: 21px;
    .bg {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .video-btn {
      width: 76px;
      height: 76px;
    }
  }
  .desc {
    font-size: 14px;
    line-height: 26px;
    height: 78px;
    color: #6a6a6a;
    .ellipsis-n(3);
    transition: all 0.2s;
  }
  .con {
    height: 32px;
    margin-top: 55px;
    width: 100%;
    overflow: hidden;
    position: relative;
    transition: all 0.2s;
    color: #808080;
    .btn {
      float: left;
      height: 32px;
      line-height: 30px;
      border-radius: 15px 15px 15px 15px;
      border: 1px solid #d8d8d8;
      font-size: 12px;
      padding: 0 16px;
    }
    .time {
      float: right;
      font-size: 14px;
      line-height: 32px;
    }
  }
}
</style>
